#!/bin/bash

rq=`date -d '1 day ago' '+%F'`
echo "开始执行反洗钱ODS->DWD数据抽取脚本，处理日期: $rq"

echo "--- Step 1: ODS→DWD 增量数据抽取 ---"
hive --hivevar etl_dt="$rq" -f /root/hive_data/aml_etl/sql/ods_to_dwd/inc_ods_to_dwd.sql > /root/hive_data/aml_etl/logs/ods_dwd/inc_ods_to_dwd_$rq.log 2>&1

if (( $? == 0 ))
then
	echo "反洗钱ODS->DWD增量数据抽取完成。"
else
	echo "反洗钱ODS->DWD增量数据抽取异常，请检查日志: /root/hive_data/aml_etl/logs/ods_dwd/inc_ods_to_dwd_$rq.log"
	exit 1
fi

echo "--- Step 2: ODS→DWD 全量数据抽取 ---"
hive --hivevar etl_dt="$rq" -f /root/hive_data/aml_etl/sql/ods_to_dwd/full_ods_to_dwd.sql > /root/hive_data/aml_etl/logs/ods_dwd/full_ods_to_dwd_$rq.log 2>&1

if (( $? == 0 ))
then
	echo "反洗钱ODS->DWD全量数据抽取完成。"
else
	echo "反洗钱ODS->DWD全量数据抽取异常，请检查日志: /root/hive_data/aml_etl/logs/ods_dwd/full_ods_to_dwd_$rq.log"
	exit 1
fi

echo "反洗钱ODS->DWD数据抽取脚本全部执行结束。"